﻿using HT.Future.Entities;
using HT.Future.IService;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace HT.Future.Service
{
    public class WxUserService : BaseService<WxUser>, IWxUserService
    {
        private ILogger<WxUserService> _logger;
        public WxUserService(HtDbContext dbContext, ILogger<WxUserService> logger) : base(dbContext)
        {
            _logger = logger;
        }

        public async Task<WxUser> GrantAsync(WxUser user)
        {
            var userinfo = await GetByIdAsync<WxUser>(user.Id);
            userinfo.NickName = user.NickName;
            userinfo.Country = user.Country;
            userinfo.Province = user.Province;
            userinfo.City = user.City;
            userinfo.Gender = user.Gender;
            userinfo.IsRegister = true;
            userinfo.FaceUrl = user.FaceUrl;
            await CommitAsync();
            return userinfo;
        }

    }
}
